package com.corpgovernment.organization.service;

import com.corpgovernment.organization.dto.AsyncDepartmentCompanyDTO;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 异步处理新增部门或者公司模版方法类
 * @author zhengshi.wang
 * @description: 抽象类异步处理新增部门或者公司模版方法类
 * @date 2024/4/2
 */
@Slf4j
public abstract class AbstractAsyncDepartmentCompany {

    /**
     * 模板方法
     * @param asyncDepartmentCompanyDTO
     */
    public final void handle(AsyncDepartmentCompanyDTO asyncDepartmentCompanyDTO){
        // 构建DTO,填充业务处理需要的数据
        buildDTO(asyncDepartmentCompanyDTO);
        // 部门权限
        handleDepartment(asyncDepartmentCompanyDTO);
        // 开票权限
        handleBilling(asyncDepartmentCompanyDTO);
        // 代订权限
        handleBookingAgent(asyncDepartmentCompanyDTO);
        // 成本中心权限
        handleCostCenter(asyncDepartmentCompanyDTO);
        // 项目权限
        handleProject(asyncDepartmentCompanyDTO);
    }

    // 查询所有子组织的orgId,不包含新增的组织ID
    abstract void buildDTO(AsyncDepartmentCompanyDTO asyncDepartmentCompanyDTO);
    abstract void handleDepartment(AsyncDepartmentCompanyDTO asyncDepartmentCompanyDTO);
    abstract void handleBilling(AsyncDepartmentCompanyDTO asyncDepartmentCompanyDTO);
    abstract void handleBookingAgent(AsyncDepartmentCompanyDTO asyncDepartmentCompanyDTO);
    abstract void handleCostCenter(AsyncDepartmentCompanyDTO asyncDepartmentCompanyDTO);
    abstract void handleProject(AsyncDepartmentCompanyDTO asyncDepartmentCompanyDTO);

    abstract void updateRedisCache(List<String> roleIdList,
                                   AsyncDepartmentCompanyDTO asyncDepartmentCompanyDTO);
}
